import * as  qiankun from 'qiankun'
import React from 'react';

const started = {

}
export const MicroApp = ({ name, entry, container = '#qiankun', activeRule, onLoad }) => {

  React.useEffect(() => {

    if(started[name]){
      return
  }

    qiankun.registerMicroApps([
      {
        name,
        container,
        activeRule,
        loader(loading) {
          // if (!loading) {
          //   onLoad()
          // }
        },
        entry
      }
    ])
    
    qiankun.start({
      singular: false
    })
    started[name] = true

  }, [])
  return <div id={(container).replace('#', '')} />
}

export const name = 'qiankun'